package com.qst.mapreduce.wordcount.kaoshi.kaoshi3;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class WeblogMapper extends Mapper<LongWritable, Text, WebLog, Text> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] words = line.split(",");
        WebLog webLog = new WebLog();
        webLog.setVisitTime(words[0]);
        webLog.setVisitIp(words[1]);
        webLog.setVisitAddress(words[2]);
        if (webLog.getVisitAddress().equals("/products")) {
            context.write(webLog, new Text("student"));
        }
    }
}
